package com.zhengshang.api.runner;

import com.zhengshang.api.service.IAppPayRecordService;
import com.zhengshang.api.task.payorder.CancelPayOrder;
import com.zhengshang.common.pay.alipay.AlipayService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

/**
 * 项目启动时加载
 */
@Component
public class CommandLineRunnerImpl implements CommandLineRunner {

    @Autowired
    private IAppPayRecordService appPayRecordService;
    @Autowired
    private AlipayService alipayService;

    @Override
    public void run(String... args) throws Exception {
        //启动加载待付款订单
        try {
            //获取待付款订单
            CancelPayOrder cancelPayOrder = new CancelPayOrder(appPayRecordService, alipayService);
            Thread thread = new Thread(cancelPayOrder, "cancelPayOrder");
            thread.start();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
